package sg.edu.nus.comp.icreate.ivletalk.utils.xml;

import java.io.InputStream;

import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;

public class UserValidateXmlParser extends AbstractXmlParser {
	private static String TARGET = "Success";

	public UserValidateXmlParser(InputStream input) throws XmlPullParserException {
		super(input);
	}

	public UserValidateXmlParser() {
		super();
	}

	@Override
	public Object getResult() {
		try {
			int eventType = parser.getEventType();
			while (eventType != XmlPullParser.END_DOCUMENT) {
				if (eventType == XmlPullParser.START_TAG && TARGET.equals(parser.getName())) {
					parser.next();
					return "true".equalsIgnoreCase(parser.getText());

				}
				eventType = parser.next();
			}
		} catch (Exception e) {
			return false;
		}
		return false;
	}

}
